package com.training.regex;

public class RegexDemo {
	public static void main(String[] args) {
		String str = "a";
		String regex = "[a-zA-Z0-9]";
		String regex2 = "[^a-z]";
		String regex3 = "\\w";//等价于[a-zA-z0-9_],匹配包括下划线的任何单词字符
		String regex4 = "\\W";//等价于[^a-zA-z0-9_],匹配任何非单词字符
		String regex5 = "\\d";//等价于[0-9],匹配任何数字字符
		String regex6 = "\\D";//等价于[^0-9],匹配任何非数字字符
		String regex7 = ".";//匹配任何除了“\n”之外的单个字符
		String regex8 = "[.]";//匹配"."
		System.out.println(str.matches(regex));
		System.out.println(str.matches(regex2));
		System.out.println(str.matches(regex3));
	}
}
